from scapy.all import sniff

def packet_callback(packet):
    print(packet.summary())

# 抓取 5 个数据包
packets = sniff(count=5, prn=packet_callback)